<?php    
header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");      
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");      
header("Cache-Control: no-cache, must-revalidate");      
header("Pragma: no-cache");    
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
html, body {
height: 100%;
width: 100%;
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
padding:10px;

border: 8px solid blue;
z-index:1002;
}
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color:#f5f5f5;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.close {
float:right;
clear:both;
width:100%;
text-align:right;
margin:0 0 6px 0
}
.close a {
color:#333;
text-decoration:none;
font-size:14px;
font-weight:700
}
.con {
text-indent:20px;
line-height:10px;
}
</style>
<script>
function show(tag){
var light=document.getElementById(tag);
var fade=document.getElementById('fade');
light.style.display='block';
fade.style.display='block';
}
function hide(tag){
var light=document.getElementById(tag);
var fade=document.getElementById('fade');
light.style.display='none';
fade.style.display='none';
}

$(function() {
	$( ".date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
	
});

function datePick(source){
	var id = $(source).attr('id');
	$("#" + id ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
}
</script> 
<title>Upate News</title>

</head>
<?php 
$dateToday = Model_DatetimeHelper::dateToday();
$leave = new Model_Hr_Staffleave();
$attRecord = new Model_DbTable_Roster_Attnrecord();
$stfInfo = new Model_DbTable_Roster_Staffinfo();
$stfDetail = new Model_DbTable_Roster_Stafflogindetail();
date_default_timezone_set('Australia/Melbourne');
				
				
?>
<body style="font-family:Arial, Helvetica, sans-serif; font-size:15px; line-height:18px; margin-top:0; margin-left:0;">

<h2>Add Roster During Annual Leave</h2>

<table width="700" border="1" cellspacing="1" cellpadding="0" style="font-size:15px;">
	<tr>
		<th>Staff</th>
		<th>Annual Leave Date</th>
		<th>Annual Leave Time</th>
		<th>ACT Login</th>		
		<th>Action</th>
	</tr>
	<?php foreach ($this->recordList as $stfId => $date){
		
			$stf = $stfInfo->getStaffinfo($stfId);
			$stfD = $stfDetail->getDetail($stfId);
			
			foreach ($date as $k => $v){
				foreach ($v as $v2){
				$num = $attRecord->getLastOnOffDuty($v2['sts']);
					if ($num == 1){
						$onDuty = date('H:i',$v2['ti']);
						$onDutyH = date('H',$v2['ti']);
						$onDutyM = date('i',$v2['ti']);
						$shop = $v2['sh'];
					}else{
						$offDuty = date('H:i',$v2['ti']);
						$offDutyH = date('H',$v2['ti']);
						$offDutyM = date('i',$v2['ti']);
						$shop = $v2['sh'];
					}
				}
			}	
			
			foreach ($date as $k => $v){
			$leaveDetail = $leave->getApproveLeaveByIdDate($stfId, $k);
			if($leaveDetail){
				?>
			
			
			<tr>
				<td align = "center"><?php echo $stf['first_name']." ".$stf['last_name']."(".$stfD['ni'].")";?></td>
				<td align = "center"><?php echo $k?></td>
				<td align = "center"><?php echo $leaveDetail['period_start_hr'].":".str_pad($leaveDetail['period_start_min'], 2, "0", STR_PAD_RIGHT)." - ".$leaveDetail['period_end_hr'].":".str_pad($leaveDetail['period_end_min'], 2, "0", STR_PAD_RIGHT);
				?></td>
				
				<td align = "center"><?php echo $onDuty." - ".$offDuty?></td>
				<td align = "center"><input type = "submit" name = "addRoster[<?php echo $stfId?>]" value = "Add Roster" onclick = "show('light')"></input></td>
			</tr>
			<tr>
				<td colspan = "5">
				<div id="light" class="white_content">
					
     				 <div class="close"><a href="javascript:void(0)" onclick="hide('light')"> Close</a></div>
					<form action = "" method = "post" enctype="multipart/form-data"> 
     				 <div class="con">
      					<h2>Insert Roster For <?php echo $stf['first_name']." ".$stf['last_name']."(".$stfD['ni'].")";?></h2>
      					Shop: <input type = "text" name = "shop[<?php echo $leaveDetail['id_leave']?>]" value = "<?php echo Model_EncryptHelper::getSslPassword($shop)?>" readonly></input><br/><br/>
      					<input type = "hidden" name = "stfId[<?php echo $leaveDetail['id_leave']?>]" value = "<?php echo $stfId?>" ></input>
      					Date: <input type = "text" name = "date[<?php echo $leaveDetail['id_leave']?>]" value = "<?php echo $k?>"></input><br/><br/>
      					On Duty: <input type = "text" name = "onDutyH[<?php echo $leaveDetail['id_leave']?>]" size = "5" value = "<?php echo $onDutyH?>"></input>:<input type = "text" name = "onDutyM[<?php echo $leaveDetail['id_leave']?>]" size = "5" value = "<?php if($onDutyM >= 00 && $onDutyM < 30){echo 00;}else{ echo 30;}?>"></input>(<?php echo $onDuty?>)<br/><br/>
      					Off Duty: <input type = "text" name = "offDutyH[<?php echo $leaveDetail['id_leave']?>]" size = "5" value = "<?php echo $offDutyH?>"></input>:<input type = "text" name = "offDutyM[<?php echo $leaveDetail['id_leave']?>]" size = "5" value = "<?php if($offDutyM >= 00 && $offDutyM < 30){echo 00;}else{ echo 30;}?>"></input>(<?php echo $offDuty?>)<br/><br/>
      					<input type = "submit" name = "submit[<?php echo $leaveDetail['id_leave']?>]" ></input>
      					
      				</div>
      				
				</form>     
				</div>
				</td>
			</tr>
			<?php }}?>
	<?php }?>

</table>



<div id="fade" class="black_overlay"></div> 



</body>
</html>
